]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
runDialog: Don’t treat empty input specially
authorLucas Werkmeister <mail@lucaswerkmeister.de>
Sun, 7 Feb 2021 18:12:57 +0000 (19:12 +0100)
committerMarge Bot <marge-bot@gnome.org>
Mon, 8 Feb 2021 08:14:46 +0000 (08:14 +0000)
Let empty input result in an error, just like other invalid commands
(bad syntax, nonempty whitespace, etc.). GLib already has an error
message “Text was empty (or contained only whitespace)” which it shows
for whitespace-only input, so letting that message apply also to empty
input makes sense.

This requires some tweaks further down the file to avoid interpreting
empty input as an empty path (relative to the home directory) and then
opening the home directory.

Part of https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3183.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1442>

js/ui/runDialog.js

index 356a974363d330a07aa82c1ac976e593218f0b93..114aa1b2657ee41d0929ef94533cd8f05e8d56b5 100644 (file)
@@ -189,7 +189,7 @@ class RunDialog extends ModalDialog.ModalDialog {
             f = null;
         if (f) {
             f();
-        } else if (input) {
+        } else {
             try {
                 if (inTerminal) {
                     let exec = this._terminalSettings.get_string(EXEC_KEY);
@@ -202,13 +202,13 @@ class RunDialog extends ModalDialog.ModalDialog {
                 let path = null;
                 if (input.charAt(0) == '/') {
                     path = input;
-                } else {
+                } else if (input) {
                     if (input.charAt(0) == '~')
                         input = input.slice(1);
                     path = '%s/%s'.format(GLib.get_home_dir(), input);
                 }
 
-                if (GLib.file_test(path, GLib.FileTest.EXISTS)) {
+                if (path && GLib.file_test(path, GLib.FileTest.EXISTS)) {
                     let file = Gio.file_new_for_path(path);
                     try {
                         Gio.app_info_launch_default_for_uri(file.get_uri(),